trigger PositionJobPostsTrigger on Position__c (after update, after delete) {

	//TODO: Create two different branches, one for each DML triggering event
	if (Trigger.isUpdate){
		//TODO: In the "update" branch, do the following:

		//TODO: Instantiate two lists called "techPositions" and "nonTechPositions"
		List<Position__c> techPositions = new List<Position__c>();
		List<Position__c> nonTechPositions = new List<Position__c>();

		//TODO: Instantiate a Set of IDs called "nonApprovedPositionIDSet"
		Set<ID> nonApprovedPositionIDSet = new Set<ID>();

		//TODO: Write a for loop to loop through the positions causing the trigger
		for(Position__c position:Trigger.new){

			//TODO: Within that loop, create two branches, one for approved positions that have Status=Open & Sub-Status=Approved, and one for the others
			if (position.Status__c == 'Open' && position.Sub_Status__c == 'Approved'){

				//TODO: Within the approved positions branch, verify that the department is not null
				if(position.Department__c != null){
					//TODO: If there is a department listed, add the position to the appropriate list (IT & Engineering = technical)
					if((position.Department__c != 'Engineering') && (position.Department__c != 'IT')){
						nonTechPositions.add(position);
					}
					else {
						techPositions.add(position);
					}
				}
				else {
					//TODO: Within the non-approved branch, add the position to the nonApprovedPositionIDSet
					nonApprovedPositionIDSet.add(position.Id);
				}
			}
		}

		//TODO: After the looping is done call the appropriate method to add the posting from the PositionJobPosts class for approved positions
		if (nonTechPositions.size() > 0) {
			PositionJobPosts.newPositionPosting(nonTechPositions,false);
		}
		if (techPositions.size() > 0) {
			PositionJobPosts.newPositionPosting(techPositions,true);
		}

		//TODO: Then call the appropriate meothod from the same class to remove postings from non-approved positions
		if (nonApprovedPositionIDSet.size() > 0) {
			PositionJobPosts.removePositionPostings(nonApprovedPositionIDSet,Trigger.newMap);
		}

	}
	else if (Trigger.isDelete){
		//TODO: In the "delete" branch, remove the position posting for the positions causing the trigger
		PositionJobPosts.removePositionPostings(Trigger.oldMap.keySet(),Trigger.oldMap);

	}
}